﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_DeleteUserBasicReferenceValues')
	BEGIN
		DROP  Procedure  esf_sso.P_DeleteUserBasicReferenceValues
	END

GO

CREATE Procedure esf_sso.P_DeleteUserBasicReferenceValues
	@pUserAlias				VARCHAR (40)
	,@pBasicReferenceTypeID	INT
AS

	DELETE FROM esf_sso.User_BasicReference_Values 
	WHERE UserPersonID = (SELECT PersonID FROM esf_sso.[User] WHERE Alias = @pUserAlias)
		AND BasicReferenceID IN (SELECT ID FROM esf_sso.BasicReference WHERE BasicReferenceTypeID = @pBasicReferenceTypeID)

GO